package com.hqyj.shop.controller;

import com.hqyj.shop.dao.GoodsDao;
import com.hqyj.shop.pojo.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

@Controller
@RequestMapping(path = "/shop")
public class GoodsController {

    @Autowired
    private GoodsDao goodsDao;
    @RequestMapping("/goods")
    public String queryAll(ModelMap modelMap){
        List<Goods> goodsList = goodsDao.goodsQueryAll();
        System.out.println(goodsList);
        modelMap.put("goodsList",goodsList);
        return "shop";
    }

    @RequestMapping("/del")
    public String delById(int goodsId){
        Goods goods = new Goods();
        goodsDao.deleteById(goods.getGoodsId());
        return "shop";
    }
}
